package com.otaku.common.ResultUtils;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.List;

@Scope //是否是单例注解,prototype:不是单例,singleton:单例，默认值
@Component
public class ResultModel implements Serializable {

    private static final long serialVersionUID = 4127034227866187008L;
    /**
     * 错误码，对应{@link ResultCode}，表示一种错误类型
     * 如果是成功，则code为200
     */
    private String code;
    /**
     * 登录token
     */
    private String token;
    /**
     * 对错误的具体解释
     */
    private String message;
    /**
     * 系统错误提示信息
     */
    private String systemMessage;
    /**
     * 返回的结果包装在value中，value可以是单个对象
     */
    private Object data;

    private String timestamp;

    public ResultModel() {
    }

    public ResultModel(String code, String token, String message, String systemMessage, Object data) {
        this.code = code;
        this.token = token;
        this.message = message;
        this.systemMessage = systemMessage;
        this.data = data;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getSystemMessage() {
        return systemMessage;
    }

    public void setSystemMessage(String systemMessage) {
        this.systemMessage = systemMessage;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object value) {
        this.data = value;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public String toString() {
        return "ApiResult{" +
                "code='" + code + '\'' +
                ", message='" + message + '\'' +
                ", systemMessage='" + systemMessage + '\'' +
                ", data=" + data +
                ", timestamp=" + timestamp +
                '}';
    }
}
